<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
<link href="css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="lib/icheck/icheck.css" rel="stylesheet" type="text/css" />
<link href="lib/Hui-iconfont/1.0.7/iconfont.css" rel="stylesheet" type="text/css" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>添加评论</title>
<style type="text/css">
 

    #autocomplate{
        position: absolute; top: 40px; width: 100%; border-radius: 5px; 
        display: none; background-color: #ddd; z-index: 1000; 
    }
    #autocomplate li{list-style: none; border-bottom: #fff 1px dashed; line-height: 35px; padding:0px 5px; cursor: pointer;}
    #autocomplate li:active{background-color: #fff; color: #333;}
    #autocomplate li:hover{background-color: #fff; color: #333;}
    #shoplist span{ padding: 3px 5px; border:#f37b1d 1px solid; border-radius: 3px; margin-right: 5px; color: #f37b1d; font-size: 12px; cursor:pointer;}
</style>
</head>
<body>
<div class="pd-20">
  <form action="" method="post" class="form form-horizontal" name="form1" id="form1">
    <div class="row cl">

        <label class="form-label col-3"><span class="c-red">*</span>评论者名称：</label>
        <div class="formControls col-6 s-msg">
            <input type="text" class="input-text" placeholder="评论名称" id="user_name" name="user_name" nullmsg="评论名称不能为空！" datatype="s1-16">
        </div>
        <div class="col-2"> </div>
    </div>
   
    <div class="row cl">
        <label class="form-label col-3"><span class="c-red">*</span>选择产品：</label>
        <div class="formControls col-6" style="position: relative;">
            <input type="text" class="input-text" value="" placeholder="" id="goods_name" onfocus="opensearch()" onblur="setTimeout(closesearch,200)" autocomplete="off" nullmsg="请选择评论商品！">
            <input type="hidden" name="goods_id" id="goods_id">
            <div id="autocomplate" class="thinklist">
                
            </div>
        </div>
    </div>
    <div class="row cl">
        <label class="form-label col-3">评论者头像：</label>
        <div class="formControls col-5">
            <div id="uploader-demo">
                <div id="imgslt" class="uploader-list fj-img">
                </div>

                <i class="Hui-iconfont fj-img-btn"  onclick="_open('评论图标','article-imageupload.html?type=image&idname=imgslt&api=user&single=1&inputname=user_avatar','710px','470px',true)">&#xe610;</i>   
                <!-- <div id="filePicker" class="btn btn-secondary radius">上传头像</div> -->
            </div>
        </div>
        <div class="col-5"> </div>
    </div>
    <div class="row cl">
        <label class="form-label col-3">评论时间：</label>
        <div class="formControls col-5">
            <input class="input-text datainp" id="addtime" type="text" name="addtime" value="" >
            
        </div>
    </div>
    <div class="row cl">
        <label class="form-label col-3">评论内容：</label>
        <div class="formControls col-8">
            <textarea name="content" id="content" cols="" rows="" class="textarea"  placeholder="说点什么...最少输入3个字符"  dragonfly="true" ></textarea>
            <p class="textarea-numberbar"></p>
        </div>
        <div class="col-4"> </div>
    </div>
    <div class="row cl">
        <label class="form-label col-3">晒图：</label>
        <div class="formControls col-8" >
            
            <span class="l mb-10 fujian" id="fujian">
                <!-- <li><img src="/Upload/article/4/5721763bd1d88.jpg"><i class="Hui-iconfont" onclick="fj_close(this);">&#xe706;</i></li> -->
            </span>
            <i class="Hui-iconfont fujianadd" onclick="_open('添加附件','article-imageupload.html?type=image&idname=fujian&api=evaluate&single=0&inputname=evaluate_images','750px','470px',true)">&#xe610;</i>
            <!-- <a id="btn-img" class="btn btn-secondary radius ml-10" onclick="_open('添加附件','article-imageupload.html?type=file&idname=fujian&api=goods&single=0&inputname=goods_images','750px','470px',true)">选择附 件</a>-->
    
            
    
        </div>
    </div>
    <div class="row cl">
        <div class="col-9 col-offset-3">
            <input class="btn btn-primary radius" type="submit" id="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
        </div>
    </div>
    </form>
</div>
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script> 

<script type="text/javascript" src="lib/Validform/5.3.2/Validform.min.js"></script>
<script type="text/javascript" src="lib/layer/2.1/layer.js"></script>
<script type="text/javascript" src="js/H-ui.js"></script> 
<script type="text/javascript" src="js/H-ui.admin.js"></script>
<script type="text/javascript" src="js/s.js"></script> 
<script type="text/javascript" src="lib/daterangepicker/moment.min.js"></script> 
<script type="text/javascript" src="lib/daterangepicker/jquery.daterangepicker.js"></script>
<link rel="stylesheet" href="lib/daterangepicker/daterangepicker.css" /> 
<script type="text/javascript">
var prevKeywordVal;
var intervalId;


// 商家列表联想搜索
function autocomplate(){
    var input=$("#goods_name");
    if(window.prevKeywordVal === $(input).val() || $(input).val()==''){
        return false;
    }
    var html='';
    var api=API_GOODS+'?t=1&k='+$(input).val();
    var autocomplate='#autocomplate';
    $.getJSON(api,function(data){
        if(!checkStatus(data)) return;
        $(autocomplate).show().html('');
        for (x in data.datas){
            html+="<li data-name="+data.datas[x].goods_name+" data-id="+data.datas[x].goods_id+">"+data.datas[x].goods_id+": "+data.datas[x].goods_name+"(销量:"+data.datas[x].goods_sales+")</li>";
        }
        $(autocomplate).html(html);
    }); 
    if($(input).val()!==''){
        prevKeywordVal=$(input).val(); 
    }
}

// 打开搜索列表
function opensearch() {
    $('#autocomplate').show();
    var html='';
    $.getJSON(API_GOODS+'?t=1',function(data){
        for (x in data.datas){
            html+="<li data-name="+data.datas[x].goods_name+" data-id="+data.datas[x].goods_id+">"+data.datas[x].goods_id+": "+data.datas[x].goods_name+"(销量:"+data.datas[x].goods_sales+")</li>";
        }
        $('#autocomplate').html(html);
    })
    intervalId=setInterval('autocomplate()',500);
}
// 关闭搜索框
function closesearch(){
    $('#autocomplate').hide();
    clearInterval(intervalId);

}


$(function(){
    // 选择评论商品
    $(document).on('click','#autocomplate li',function(){
        var id=$(this).data("id");
        var name=$(this).data("name");

        $("#goods_name").val('id:'+id+' '+name);
        $("input[name=goods_id]").val(id);
    
    })
    

    var editid=getUrlParam('editid');//编辑评论id
    $("#form1").attr("action", API_ORDEREVALUATE);

    $('#addtime').dateRangePicker(
    {
        autoClose: true,
        singleDate : true,
        showShortcuts: false,
        singleMonth: true,


        startOfWeek: 'monday',
        format: 'YYYY-MM-DD HH:mm:ss',
        time: {
            enabled: true
        },
        defaultTime: moment().startOf('day').toDate(),
        defaultEndTime: moment().endOf('day').toDate(),

    });





    if(editid!=null){
        
        var eidturl=API_ORDEREVALUATE+"?aid="+editid;

        $.getJSON(eidturl,function(data){
            if(!checkStatus(data)) return;//判断登录

            if(data.datas==''){
                layer.msg("数据加载错误", {icon:2,time:1000});
            }else{
                $("#user_name").val(data.datas.user_name);
                $("#goods_name").val(data.datas.goods_name);
                $("#addtime").val(data.datas.addtime);
                $("#goods_id").val(data.datas.goods_id);
                
                $("#content").val(data.datas.content);

                $("#form1").attr("action", eidturl);
                

                // 缩略图
                if(data.datas.user_avatar){
                    var user_avatar=data.datas.user_avatar;
                    $('#imgslt').append('<li><img src="'+user_avatar+'"><i class="Hui-iconfont fun-img-del" data-id="#imgslt" data-inputname="user_avatar">&#xe706;</i><input type="hidden" name="user_avatar" value="'+user_avatar+'"></li>');                        
                }

                var goods_images=data.datas.evaluate_images;
                for (x in goods_images){
                    $('#fujian').show();
                    $('#fujian').append('<li><img src="'+getIcon(goods_images[x])+'"><i class="Hui-iconfont" onclick="fj_close(this);">&#xe706;</i><input type="hidden" name="evaluate_images['+x+']" value="'+goods_images[x]+'"></li>');    
                }
            }
            
        })
    }


    Validformsubmit("#form1");
});

// 移除选中的图片
function fj_close(obj){
    $(obj).parents("li").remove();
}

</script>
</body>
</html>